<%@ page language="java" contentType="text/html; charset=UTF-8" pageEncoding="UTF-8"%>
<%@ taglib uri="/struts-tags" prefix="s"%>
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
<meta http-equiv="Cache-Control" content="no-cache" />
<meta http-equiv="Progma" content="no-cache" />
<link rel="stylesheet" href="<%=request.getContextPath()%>/css/mm_training.css" type="text/css" />
<link rel="stylesheet" href="<%=request.getContextPath()%>/css/user.css" type="text/css" />
<link type="text/css" href="<%=request.getContextPath() %>/css/smoothness/jquery-ui-1.7.1.custom.css" rel="stylesheet"/>
<script type="text/javascript" src="<%=request.getContextPath() %>/scripts/jquery/jquery-1.3.2.js"></script>
<script type="text/javascript" src="<%=request.getContextPath() %>/scripts/jquery/jquery-ui-1.7.1.custom.js"></script>
<script type="text/javascript">
	/**
	 * 
	 * 修改密碼
	 *
	 */ 
	function changePass() {
		var context = '<%=request.getContextPath()%>';
		// 獲取登陸數據
		var params = $("#changeForm").serialize();
		// 請求開始時提示消息
		$("#loading").ajaxStart(function(){
			   $(this).dialog({
				   title:"正在修改密碼,請稍等.......",
				   modal:true,
				   height:0,
				   resizable:false,
				   draggable:false
			   });
		});
		// 請求完成
		 $("#loading").ajaxComplete(function(request, settings){
			 $(this).dialog("destroy");
		});
		// 提交請求
		$.ajax({
			   url: context + "/changePassword.do",
			   data: params,
			   dataType:"html",
			   success: function (data) {
					// 清除所有錯誤消息 
				   $("span[id^='err_msg_']").each(function (index) {
					   // 清空錯誤消息
					   $(this).text("");
				   });
				   var errorMessage = $("li",data);
				   // 如果存在錯誤消息
				   if (errorMessage.length > 0) {
					   // 獲取消息
					   errorMessage.each(function (index) {
							// 獲取發生錯誤的字段ID
						   var id = $(this).attr("id");
						   // 獲取錯誤消息
						   var value = $(this).text();
						   // 顯示錯誤消息地方
						   var errorID = "err_msg_" + id;
						   // 設置錯誤消息
						   $("#" + errorID).text(value);
					   });
				   } else {
					   alert("密碼修改成功");
					   $(":password").each(function (index){
						   	$(this).val("");
					   });
				   }
			   },
		   	   error: function (data) {
			   	   document.location.href = context + "/error.jsp?random=" + Math.random();
			   }
		});
		// 不提交表单
		return false;
	}
</script>

<style type="text/css">
	.sidebarText {
		text-align: right;
	}
	.err_msg {
		color: red;
		font-size: 12px;
	}
	body {
		font-size: 12px;
	}
</style>
<title>客服中心</title>
</head>
<body bgcolor="#64748B">
<jsp:include page="/head.jsp"></jsp:include>
	<td width="230" valign="top" bgcolor="#26354a" colspan="2">
		<table width="230" cellspacing="0" cellpadding="0" border="0">
			<tbody>
				<tr>
				<td width="230" id="padding" class="sidebarText"><a href="#">密码修改</a><br/>
				<br/></td>
				</tr>
				<tr>
				<td width="230" id="padding" class="sidebarText"><br/>
				<br/></td>
				</tr>
				<tr>
				<td width="230" id="padding" class="sidebarText"><br/>
				<br/></td>
				</tr>
			</tbody>
		</table>
	</td>
	<td valign="top" width='100%'>
		<form id="changeForm" action="<%=request.getContextPath() %>/changePassword.do" method="post">
			<div id="pagetest" style="border:1px solid #DADADA;min-width:700px;">
				<table width="100%" cellspacing="0" cellpadding="0" border="0">
					<tbody>
						<tr>
						<td class="sidebarText" width="20%">錄入現在的密碼
						</td>
						<td align="left">
						<input type="password" id="oldpass" name="oldpass"/><span id="err_msg_oldpass" class="err_msg"></span>
						</td>
						</tr>
						<tr>
						<td class="sidebarText">錄入新密碼
						</td>
						<td align="left">
						<input type="password" id="newpass" name="newpass"/><span id="err_msg_newpass" class="err_msg"></span>
						</td>
						</tr>
						<tr>
						<td class="sidebarText">再錄入一次新密碼
						</td>
						<td align="left">
						<input type="password" id="newpassagain" name="newpassagain"/><span id="err_msg_newpassagain" class="err_msg"></span>
						</td>
						</tr>
						<tr>
						<td align="center" colspan="2">
							<input type="button" name="change" value="修改" onclick="changePass();"/>
						</td>
						</tr>
					</tbody>
				</table>
			</div>
		</form>
	</td>
	<div id="loading" style="color: red; display: none;">loading........</div>
<jsp:include page="/footer.jsp"></jsp:include>
</body>
</html>